{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "1、有一个列表，里面装着很多用户的评论，为了页面正常展示，\n",
    "需要将所有的超过一定长度(假设超过10个字符)的评论用省略号替代，\n",
    "写出一个add_ellipsis函数来实现\n",
    "2、要求同上，要求返回的结果为元组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 农村规划，仔细地去规划了农田,那个方向，不言而喻。如果是只针对生态进行规划，单一方向的规划带来的不稳定性和高成本又该如何解决"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['农村规划', '仔细地去规划了农田', '是只针对生态进行规划', '单一方向的规划带来的不稳定性和高成本又该如何解决']\n",
      "4\n",
      "('农村规划', '仔细地去规划了农田', '是只针对生态进行规划', '单一方向的规划带来的不稳定性和高成本又该如何解决', '农村规...')\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "('农村规划', '仔细地去规划了农田', '是只针对生态进行规划', '单一方向的规划带来的不稳定性和高成本又该如何解决', '农村规...')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#  此为作业正文\n",
    "messages = ['农村规划','仔细地去规划了农田','是只针对生态进行规划','单一方向的规划带来的不稳定性和高成本又该如何解决']\n",
    "newcomments = []\n",
    "def add_ellipsis(newcomments):\n",
    "    print(newcomments)\n",
    "    lenth = len(newcomments)\n",
    "    print(lenth)\n",
    "    for i in range(lenth):\n",
    "        if len(newcomments[i]) > 3:\n",
    "            a = newcomments[i][:3] + '...'\n",
    "            newcomments.append(a)\n",
    "        else:\n",
    "            newlist.append(i)\n",
    "        print(tuple(newcomments))\n",
    "        return tuple(newcomments)\n",
    "    \n",
    "add_ellipsis(messages)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
